#ifndef RECT_H_
#define RECT_H_

// By: Jesse Guarascia de Urena
// Rectangle class
// Used for rectangle positioning

#include <SDL.h>
#include "Point2D.h"

class Rect
{
private:
	Point2D point; // Point of the x, y of the rect

public:
	Rect(void);
	Rect(float _top, float _left, float _bottom, float _right);
	~Rect(void);

	// Sides of the rectangle
	float top, left, right, bottom;

	// Translate to the point of the rectangle
	void TranslateTo();

	// Set the size of the rectangle
	void SetSize(float width, float height);

	// Convert the rectangle to an SDL_Rect
	SDL_Rect ToSDLRect();

	// Convert the rectangle to OpenGL texture coordinates
	Rect ToTexCoords(float texWidth, float texHeight);

	// Move the rectangle
	void Move(float amount, int direction);

	// Set the position of the rectangle
	void SetPos(float _left, float _top);
	void SetLeft(float _left);
	void SetTop(float _top);
	void SetCenter(float newX, float newY);

	// Get the center points of the rectangle
	inline float CenterX() { return right - (right - left) / 2; }
	inline float CenterY() { return bottom - (bottom - top) / 2; }

	// Get the sizes of the rect
	inline float Width() { return right - left; }
	inline float Height() { return bottom - top; }

	// Get the drawing coordinates of the rectangle
	inline float DrawLeft() { return left - CenterY(); }
	inline float DrawTop() { return top - CenterX(); }
	inline float DrawRight() { return right - CenterY(); }
	inline float DrawBottom() { return bottom - CenterX(); }

	// Check collision
	bool CheckCollision(Rect rect);
	static bool CheckCollision(Rect first, Rect second);
};

#endif // RECT_H_

